package www.openteam.com.presenter.prdctnMngmnt;

import java.util.HashMap;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.MoneyType;
import www.openteam.com.bean.PayType;
import www.openteam.com.bean.SRCKPlanMsg;
import www.openteam.com.bean.SRCPoduMsg;
import www.openteam.com.contract.PrdctnMngmnt.SendRCKContract;
import www.openteam.com.model.PrdctnMngmnt.SendRCKModel;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.prdctnMngmnt.SendRCheckFragment;

/**
 * Created by Administrator on 2019-06-19.
 */

public class SendRCKPrst extends BasePresenter<SendRCheckFragment> implements
        SendRCKContract.SendRCKPresent {

    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new SendRCKModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String, IModel> hashMap = new HashMap<>();
        hashMap.put("SendRCKModel", models[0]);
        return hashMap;
    }

    @Override
    public void findMoneyType() {
        ((SendRCKModel) getiModelMap().get("SendRCKModel")).findMoneyType(new SendRCKModel.MoneyTypeListener() {
            @Override
            public void success(MoneyType moneyType) {
                getIView().findMoneryType(moneyType);
            }

            @Override
            public void fail(Throwable e) {
                getIView().findMoneryTypeFail(e.getMessage());
            }
        });
    }

    @Override
    public void findPayType() {
        ((SendRCKModel) getiModelMap().get("SendRCKModel")).findPayType(new SendRCKModel.PayTypeListener() {
            @Override
            public void success(PayType payType) {
                getIView().findPayType(payType);
            }

            @Override
            public void fail(Throwable e) {
                getIView().findPayTypeFail(e.getMessage());
            }
        });
    }

    @Override
    public void findPoduMsg() {
        ((SendRCKModel) getiModelMap().get("SendRCKModel")).findSRCPoduMsg(new SendRCKModel.PoduMsgListener() {
            @Override
            public void success(SRCPoduMsg srcPoduMsg) {
                getIView().findPoduMsg(srcPoduMsg);
            }

            @Override
            public void fail(Throwable e) {
                getIView().findPoduMsgFail(e.getMessage());
            }
        });
    }

    @Override
    public void findPlanMsg(String code) {
        ((SendRCKModel) getiModelMap().get("SendRCKModel")).findPlanMsg(code, new SendRCKModel.PlanMsgListener() {
            @Override
            public void success(SRCKPlanMsg srckPlanMsg) {
                getIView().findPlanMsg(srckPlanMsg);
            }

            @Override
            public void fail(Throwable e) {
                getIView().findPlanMsgFail(e.getMessage());
            }
        });
    }
}